package com.binarytree.simple;

public class BinaryTree {
    private Node root;

    public void setRoot(Node root) {
        this.root = root;
    }

    // 前序遍历
    public void preOrder() {
        if (root == null) {
            throw new RuntimeException("空二叉树，无法遍历");
        }

        root.preOrder();
    }

    // 中序遍历
    public void infixOrder() {
        if (root == null) {
            throw new RuntimeException("空二叉树，无法遍历");
        }

        root.infixOrder();
    }
    // 后序遍历
    public void postOrder() {
        if (root == null) {
            throw new RuntimeException("空二叉树，无法遍历");
        }

        root.postOrder();
    }

    // 前序查找
    public Node preOrderSearch(int data) {
        return root.preOrderSearch(data);
    }
    // 前序查找
    public Node infixOrderSearch(int data) {
        return root.infixOrderSearch(data);
    }
    // 前序查找
    public Node postOrderSearch(int data) {
        return root.postOrderSearch(data);
    }
}
